package com.threadpool;

import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;


public class App {

    public static class Dog {
        volatile String name = "dog1";

    }

    public static void main(String[] args) throws Exception {
        AtomicReferenceFieldUpdater updater = AtomicReferenceFieldUpdater.newUpdater(Dog.class, String.class, "name");
        Dog dog1 = new Dog();
        updater.compareAndSet(dog1, dog1.name, "test");
        System.out.println(dog1.name);

    }
}



